package com.tfswue.qiu.controller;

import com.tfswue.qiu.entity.Order;
import com.tfswue.qiu.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
*
* 通过order远程调用user服务，获取用户信息，
*
* */
@RestController
@RequestMapping(value = "/api/orders")
@RefreshScope
public class OrderController {
    @Autowired
    private OrderService orderService;

    // nacos 读取配置
    @Value("${server.port}")
    private String port;
    @GetMapping("/port")
    public String getPort() {
        return "端口:" + port;
    }
    @Value("${config.info}")
    private String configInfo;
    @GetMapping("/config/info")
    public String getConfigInfo() {
        return "configInfo:" + configInfo;
    }
    @GetMapping("/{id}")
    public Order getOrderById(@PathVariable("id") Integer id) {
        return orderService.getOrderById(id);
    }
}
